package data;

import net.sf.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.Properties;

public class GetDimension {
    private Properties properties = new Properties();

    public GetDimension() {
        InputStreamReader inputStreamReader;
        try {
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            InputStream inputStream = classLoader.getResourceAsStream("dimension.properties");
            inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
            properties.load(inputStreamReader);
            inputStreamReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getItemList() {
        JSONObject jsonObject = new JSONObject();
        Enumeration<?> enumeration = properties.propertyNames();
        while (enumeration.hasMoreElements()) {
            String key = (String) enumeration.nextElement();
            String item = properties.getProperty(key);
            jsonObject.put(key, item);
        }
        return jsonObject.toString();
    }
}
